package br.edu.ufcg.lsd.wbis.ui.client.ui.setup;

import br.edu.ufcg.lsd.wbis.ui.client.services.SetupService;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.PanelManager;

import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;

/**
 * @author Renato Miceli
 */
public class CancelAndForbidRootCreationListener extends ButtonListenerAdapter {

	private final PanelManager panelManager;

	public CancelAndForbidRootCreationListener(PanelManager panelManager) {
		this.panelManager = panelManager;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void onClick(Button button, EventObject e) {
		MessageBox.confirm("Confirm", "Are you sure you want to forbid the root user creation? ", new MessageBox.ConfirmCallback() {
			public void execute(String btnID) {
				if (btnID.equals("yes")) {
					SetupService.Util.getInstance().forbidRootCreation(new CancelAndForbidRootCreationCallback(panelManager));
				}
			}
		});
	}

}
